<?php

namespace app\admin\model\wanlshop;

use think\Model;
use traits\model\SoftDelete;


class Verification extends Model
{

    use SoftDelete;

    protected $pk = "id";

    // 表名
    protected $name = 'wanlshop_verification';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'status_text'
    ];



    public function getStatusList()
    {
        return ['1' => __('正常'),'0' => __('隐藏')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id')->setEagerlyType(0);
    }

    // 关联 AddressSpot 表
    public function spot()
    {
        return $this->belongsTo('app\admin\model\wanlshop\AddressSpot', 'address_spot_id', 'id')->setEagerlyType(0);
    }
}
